package jpb.module.dao.profession;

import jpb.module.dao.profession.mapper.ProfessionMapper;
import jpb.module.daomain.profession.Profession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by haol on 2017/4/5.
 */
@Repository
public class ProfessionDao {
        @Autowired
        private ProfessionMapper mapper;

        private Logger logger = LoggerFactory.getLogger(ProfessionDao.class);

        public void add(Profession profession) {
                try {
                        mapper.add(profession);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }

        public void delete(Integer id) {
                try {
                        mapper.delete(id);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }
        public void delete(String oid) {
                try {
                        mapper.deleteByOid(oid);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }

        public void update(Profession profession) {
                try {
                        mapper.update(profession);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                }
        }


        public List<Profession> getByOid(String oid) {
                try {
                        return mapper.get(oid);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

        public Profession get(int id) {
                try {
                        return mapper.getById(id);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

        public Profession get(String oid, String name) {
                try {
                        return mapper.getByOidAndName(oid, name);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }
        public Profession getByOidAndNum(String oid, String memberNum) {
                try {
                        return mapper.getByOidAndNum(oid, memberNum);
                } catch (Exception e) {
                        logger.error(e.getMessage());
                        return null;
                }
        }

}
